package com.cmcc.groupcontacts.numbersearch.dao;

import java.util.ArrayList;

import com.cmcc.groupcontacts.base.BaseDAO;
import com.cmcc.groupcontacts.base.BaseModel;
import com.cmcc.groupcontacts.numbersearch.model.NumberCategory;

public class NumberCategoryDao extends BaseDAO<NumberCategory> {

	public static String TABLE_NAME = "numbercategory";
	public NumberCategoryDao() {
		super(TABLE_NAME);
	}
	
	@Override
	protected NumberCategory getInstance() {
		return new NumberCategory();
	}

	@Override
	protected String[] getBeanAllCols() {
		return NumberCategory.MetaData.ALL_COLS;
	}

	@Override
	protected void afterGetColValue(BaseModel bean, String colName, String value) {
		super.afterGetColValue(bean, colName, value);
		NumberCategory item = (NumberCategory) bean;
		if (NumberCategory.MetaData.id.equals(colName))
			item.id = Integer.valueOf(value);
		else if (NumberCategory.MetaData.name.equals(colName))
			item.name = value;
		else if (NumberCategory.MetaData.numberCount.equals(colName))
			item.numberCount = Integer.valueOf(value);
	}
	
	public ArrayList<NumberCategory> load(){
		return query("select * from numbercategory" );
	}
}
